#!/bin/sh

# The OpenWrt Hostname in System
ROUTER=OpenWrt-WRTSL54GS


cd /mnt/sda1/TED/daily_archives
mkdir `date +%Y%m%d`
cd `date +%Y%m%d`

rrdtool graph '1.86400.png' '-a' PNG '-s' 'NOW-86400' '-w' 400 '-t' "$ROUTER"': KiloWatt Hours used ' '-v' 'kilowatt hours' 'DEF:1kwhrtdysum_avg=/tmp/'"$ROUTER"'/ted/kwhrtdysum.rrd:value:AVERAGE' 'CDEF:1kwhrtdysum_nnl=1kwhrtdysum_avg,UN,0,1kwhrtdysum_avg,IF' 'CDEF:1kwhrtdysum_stk=1kwhrtdysum_nnl' 'LINE1:1kwhrtdysum_stk#0000ff:kwhrtdysum__value' 'GPRINT:1kwhrtdysum_avg:AVERAGE: Avg\: %6.1lf' 'GPRINT:1kwhrtdysum_avg:LAST:	Last\: %6.1lf\l'
rrdtool graph '2.86400.png' '-a' PNG '-s' 'NOW-86400' '-w' 400 '-t' "$ROUTER"': KiloWatts used right now ' '-v' kilowatts 'DEF:1kwnowdsp_avg=/tmp/'"$ROUTER"'/ted/kwnowdsp.rrd:value:AVERAGE' 'CDEF:1kwnowdsp_nnl=1kwnowdsp_avg,UN,0,1kwnowdsp_avg,IF' 'CDEF:1kwnowdsp_stk=1kwnowdsp_nnl' 'LINE1:1kwnowdsp_stk#0000ff:kwnowdsp__value' 'GPRINT:1kwnowdsp_avg:AVERAGE:	Avg\: %6.1lf' 'GPRINT:1kwnowdsp_avg:LAST:	Last\: %6.1lf\l'

cp /tmp/OpenWrt-WRTSL54GS/ted/kwhrtdysum.rrd .
cp /tmp/OpenWrt-WRTSL54GS/ted/kwnowdsp.rrd .

chmod 444 *

